﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DA;
using Businis;
using System.Linq;

namespace qlhocsinh
{
    public partial class Frbangdiemmonhoc : Form
    {
        public Frbangdiemmonhoc()
        {
            InitializeComponent();
        }
        bangdiemmonhoc_BUS bd = new bangdiemmonhoc_BUS();
        private void button1_Click(object sender, EventArgs e)
        {
            BANGDIEM bdmh = new BANGDIEM();
            bdmh.MALOP = cblop.SelectedValue.ToString();
            bdmh.MAHK = cbhocky.SelectedValue.ToString();
            bdmh.MAMH = cbmon.SelectedValue.ToString();
            dataGridView1.DataSource = bd.layalltheoma(bdmh);
            for (int i = 0; i <= dataGridView1.Rows.Count-1; i++)
            {
                dataGridView1.Rows[i].Cells[0].Value = i + 1;
            }
        }
        void combo()
        {
            DataLINQHocSinhDataContext dt = new DataLINQHocSinhDataContext();
            var cb = (from a in dt.BANGDIEMs select new { a.MAHK }).Distinct().ToList();
            cbhocky.DataSource = cb;
            cbhocky.DisplayMember = "MAHK";
            cbhocky.ValueMember = "MAHK";

        }
        private void Frbangdiemmonhoc_Load(object sender, EventArgs e)
        {
            combo();
            cblop.DataSource = bd.layallml();
            cblop.DisplayMember = "TenLop";
            cblop.ValueMember = "MALOP";
            cbmon.DataSource = bd.layallmh();
            cbmon.DisplayMember = "TenMH";
            cbmon.ValueMember = "MAMH";

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult a = MessageBox.Show("bạn có chắc chắn muốn thoát?", "thoát", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            if (DialogResult.OK == a)
            {
                this.Close();
            }
        }
    }
}
